package com.song.tools.log.operatelog.annotation;

import com.song.tools.log.operatelog.enums.ActionTypeEnum;
import com.song.tools.log.operatelog.enums.ModuleEnum;

import java.lang.annotation.*;

/**
 * 操作日志注解
 * <pre>
 * <ul>使用示例：
 * <li>@OLog(template = "这是简单模版，无参数",actionType = ActionTypeEnum.UPDATE,actionIdEl = "{#userReq.id}",moduleEl = "1")</li>
 * <li>@OLog(template = "带参数模版，学生名称：{#userReq.name},班级名称：{#userReq.classReq.name}",actionTypeStr = "这是操作",actionIdEl = "{#userReq.id}")</li>
 * <li>@OLog(template = "带参数计算模版，{#userReq.classReq.number > 20?'大班':'小班'}",actionTypeStr = "这是操作",actionIdEl = "{#userReq.id}")</li>
 * <li>@OLog(template = "复杂模版，{#userReq.classReq.number > 20?'大班':('这是名称:').concat(#userReq.name).concat(',这是年龄：').concat(#userReq.age)}",actionTypeStr = "这是操作",actionIdEl = "{#userReq.id}")</li>
 * <li>@OLog(template = "自定义表达式处理，{SfObjectUtil.isEmpty(#userReq.id)?'id为0或者为空':'id不为0或者为空'}",actionTypeStr = "这是操作",actionIdEl = "{#userReq.id}")</li>
 * <li>@OLog(template = "自定义处理，{logDesc}",actionTypeStr = "这是操作",actionIdEl = "{id}")</li>
 * </ul>
 * </pre>
 *
 * @author song tools
 * @since 2024-07-03
 */
@Documented
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
public @interface OLog {
    /**
     * 日志模版
     */
    String template();

    /**
     * 模块
     */
    ModuleEnum module() default ModuleEnum.DEFAULT;


    /**
     * 所属模块名
     */
    String moduleStr() default "";

    /**
     * 所属模块名</br>
     * 变量/表达式获取
     */
    String moduleEl() default "";

    /**
     * 操作类型
     */
    ActionTypeEnum actionType() default ActionTypeEnum.DEFAULT;

    /**
     * 操作类型，优先级高于枚举；不为空时强制读取此值
     */
    String actionTypeStr() default "";

    /**
     * 操作类型</br>
     * 变量/表达式获取
     */
    String actionTypeEl() default "";

    /**
     * 业务操作唯一值</br>
     * 变量/表达式获取
     */
    String actionIdEl() default "";

    /**
     * 业务操作唯一值,多值
     */
    String actionIds() default "";

    /**
     * 扩展字段
     */
    String ext() default "";
}
